export default config = {
  httpUrl: 'http://172.16.2.27:8000',
  userLogin: async ({userName, passWord}) => {
    console.log({userName, passWord});

    let result = await fetch(config.httpUrl + '/api/login', {
      method: 'post',
      headers: {'Content-type': 'application/json;charset=utf-8'},
      //   mode: 'cors',
      // NODE后台，必须要用stringify()转换数据；
      body: JSON.stringify({userName, passWord}),
    })
      .then(res => {
        console.log(res);
        return res.json();
      })
      .then(res => {
        // console.log(res);
        return res.data;
      })
      .catch(err => console.log(err));

    console.log(result);
    return result;
  },
  // 添加这个方法后，组件里面调用此方法时，一直报错。重新启动npm start后，正常了。
  getProductList: async ({nowPage, pageCount}) => {
    let result = await fetch(config.httpUrl + '/api/getTeamContractList', {
      method: 'post',
      headers: {'Content-type': 'application/json;charset=utf-8'},
      body: JSON.stringify({nowPage, pageCount}),
    })
      .then(res => {
        return res.json();
      })
      .then(res => {
        // console.log(res);
        return res.data;
      })
      .catch(err => console.log(err));

    return result;
  },
};
